package com.gladlee.myACP.tool;

import static com.gladlee.myACP.tool.myAtomTool.getBytes;
import static com.gladlee.myACP.tool.myAtomTool.getInt;
import static com.gladlee.myACP.tool.myAtomTool.getLong;
import static java.lang.System.out;

import com.gladlee.ACP.Atom;
import com.gladlee.ACP.AtomUser;
import com.gladlee.myACP.myAtomUser;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		atomTest();
//		num();

	}

	public static void num() {
		byte[] bs=getBytes(232345);
		int n=getInt(bs);
		out.println(n);
	}

	public static void num2() {
		long l = 123;
		byte[] bs = getBytes(l);
		l = getLong(bs);
		out.println(l);
	}

	public static void atomTest() {
		Atom atom = new Atom("59.66.136.193");
		AtomUser user = new myAtomUser();
		atom.regUser(user);
		String cc = "ACPower",cc2="ACFlow",cc3="ACBrand";
		user.putDoubleData(cc, -1234.5678);
		user.putIntData(cc2, -6434234);
		user.putStringData(cc3, "gladlee!");
		user.putStringData("ips", "59.66.166.93");
		atom.work();
		while (true) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if (atom.getADFIn().size() > 0) {
				double d = atom.getDoubleData(cc);
				int n=atom.getIntData(cc2);
				String s=atom.getStringData(cc3);
				out.println(d);
				out.println(n);
				out.println(s);
			}
		}
	}

	public static void number() {
		String cc = "ACPower";
		int l = cc.length();
		byte[] b = cc.getBytes();
		byte[] b2 = new byte[l + 2];
		b2[0] = 0;
		b2[1] = 0;
		for (int i = 0; i < l; i++) {
			b2[i + 2] = b[i];
		}
		// b2[l]=0x00;
		// b2[l]=0x00;
		// String s=b2.toString();
		String s = new String(b2).trim();
		out.println(s);

	}

}
